package net.zjitc.controller;

import net.zjitc.pojo.User;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Controller
@RequestMapping(value = "/admin")
public class AdminController {
    @RequestMapping(value = "/login")
    public String login(User user,
                        Model model){
        System.out.println(user.getUsername());
        System.out.println(user.getPassword());
        model.addAttribute("msg","登录成功");
        return "msg";
    }
//    public String login(@RequestParam(name="username") String name,
//                        @RequestParam(name="password") String pass,
//                        Model model){
//        System.out.println(name);
//        System.out.println(pass);
//        model.addAttribute("msg","登录成功");
//        return "msg";
//    }
//    public ModelAndView login_submit(HttpServletRequest request,HttpServletResponse response){
//        String username = request.getParameter("username");
//        String password = request.getParameter("password");
//        ModelAndView modelAndView = new ModelAndView();
//        if("admin".equals(username)){
//            if("123".equals(password)){
//                modelAndView.addObject("msg","登录成功");
//                modelAndView.setViewName("msg");
//                return modelAndView;
//            }
//        }
//        modelAndView.addObject("msg","登录失败");
//        modelAndView.setViewName("msg");
//        return modelAndView;
//    }
    @RequestMapping(value = "/loginUI")
    public ModelAndView loginUI(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("login");
        return modelAndView;
    }
    @RequestMapping(value = "/test")
    public ModelAndView test()  {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","test web...");
        modelAndView.setViewName("msg");
        return modelAndView;
    }
    @RequestMapping(value = "/add")
    public ModelAndView add()  {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","add web...");
        modelAndView.setViewName("msg");
        return modelAndView;
    }
}
